package ControlLayer;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import ModelLayer.Customer;

public class CustomerCtrlTest 
{
	private CustomerCtrl CustCtrlObj;

	@Before
	public void setUp() throws Exception 
	{
		CustCtrlObj = new CustomerCtrl();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testFindAllCustomers()
	{
		ArrayList<Customer> customers = CustCtrlObj.findAllCustomers();
		for(Customer cust : customers)
		{
			System.out.println("" + cust.getName());
		}
	}

	@Test
	public void testFindCustomerByName() 
	{
		Customer customerObject = CustCtrlObj.findCustomerByName("Johnny Madsen");
		if(customerObject != null)
		{
			System.out.println("Kunde fundet: " + customerObject.getName());
		}
		else
		{
			fail("Kunden blev ikke fundet");
		}
	}

	@Test
	public void testInsertNewCust()
	{
		CustCtrlObj.insertNewCust("Mark Markson", "Steffenvej 12", "9200", "12345678", false);
	}

	@Test
	public void testUpdateCust()
	{
		CustCtrlObj.updateCust("Mark Markson", "Jespervej 251", "9000", "87654321", false);
	}

	@Test
	public void testDeleteCust()
	{
		CustCtrlObj.deleteCust("Mark Markson");
	}
}
